package com.quyeying.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quyeying.entity.TblBusinessLicenceEntity;
import com.quyeying.mapper.TblBusinessLicenceDao;
import com.quyeying.service.TblBusinessLicenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.quyeying.utils.result.R;
import com.quyeying.utils.result.ReturnPageData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
* <p>
 * 许可证信息表 服务实现类
 * </p>
*
* @author jll
* @since 2022-12-14
*/
@Service
public class TblBusinessLicenceServiceImpl extends ServiceImpl<TblBusinessLicenceDao, TblBusinessLicenceEntity> implements TblBusinessLicenceService {

    @Override
    public R findListByPage(Integer page, Integer pageCount){
        IPage<TblBusinessLicenceEntity> wherePage = new Page<>(page, pageCount);
        TblBusinessLicenceEntity where = new TblBusinessLicenceEntity();
        IPage<TblBusinessLicenceEntity> iPage = baseMapper.selectPage(wherePage, Wrappers.query(where));
        return R.success(ReturnPageData.fillingData(iPage));
    }

    @Override
    public R add(TblBusinessLicenceEntity tblBusinessLicenceEntity){
        baseMapper.insert(tblBusinessLicenceEntity);
        return R.success();
    }

    @Override
    public R delete(Long id){
        baseMapper.deleteById(id);
        return R.success();
    }

    @Override
    public R updateData(TblBusinessLicenceEntity tblBusinessLicenceEntity){
        baseMapper.updateById(tblBusinessLicenceEntity);
        return R.success();
    }

    @Override
    public R findById(Long id){
        TblBusinessLicenceEntity tblBusinessLicenceEntity = baseMapper.selectById(id);
        return R.success(tblBusinessLicenceEntity);
    }

    @Override
    public R findList() {
        return R.success(baseMapper.selectList(new QueryWrapper<>()));
    }
}
